package com.jy.api;

import com.baidu.aip.speech.AipSpeech;
import com.jy.api.domain.*;
import com.thoughtworks.xstream.XStream;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * Created by hanxi on 2017/7/3.
 */
@Configuration
public class AppConfig {
    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) {
        return builder.build();
    }

    @Bean
    public AipSpeech baiduAipSpeech() {
        AipSpeech client = new AipSpeech("11019528", "tLlGs9eOGD41PkmviBSngBpI", "1cd6fecfae13317dea28f5ab6d1c1824");

        // 可选：设置网络连接参数
        client.setConnectionTimeoutInMillis(2000);
        client.setSocketTimeoutInMillis(60000);
        return client;
    }

    @Bean
    public XStream xstream() {
        XStream xstream = XStreamInitializer.getInstance();
        xstream.processAnnotations(SwiftPassMicroPayBaseResult.class);
        xstream.processAnnotations(SwiftPassPaymentQueryBaseResult.class);
        xstream.processAnnotations(SwiftPassReversePaymentResult.class);
        xstream.processAnnotations(SwiftPassQRCodePayResult.class);
        xstream.processAnnotations(SwiftPassPaymentNotify.class);
        xstream.processAnnotations(SwiftPassJSPayResult.class);
        xstream.processAnnotations(SwiftPassRefundQueryResult.class);
        xstream.processAnnotations(SwiftPassRefundResult.class);

        xstream.ignoreUnknownElements();

        return xstream;
    }
}
